namespace CSharpePro._0928;

public class Cycle
{
    public void NarcissusNumber()
    {

        int hundred;
        int ten;
        int unit;
        Console.WriteLine("1000以内水仙花数有：");
        for (int i = 100; i < 1000; i++)
        {
            hundred = i /100;
            ten = (i / 10)%10;
            unit= i % 10;
            if (i == hundred*hundred*hundred + ten*ten*ten + unit*unit*unit)
            {
                Console.Write(i+" ");
            }
            
        }
    }

    public void PrimeNumber()
    {
        Console.Write("\n");
        Console.WriteLine("100以内的质数有：");
        for (int i = 2; i <= 100; i++)
        {
            bool prime = true;
            for (int j = 2; j <i; j++)
            {
                if (i % j == 0)
                { 
                    prime = false;
                    break;
                }
            }

            if (prime)
            {
                Console.Write(i + " ");
            }
        }

       
    }
}